package cn.ezios.huo.system.biz.menu;

import cn.ezios.huo.common.mvc.Ret;
import cn.ezios.huo.system.dao.domain.SysMenu;
import cn.ezios.huo.system.dao.service.SysMenuService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/v1/sys/menu")
@RequiredArgsConstructor
public class MenuController {

    private final MenuService menuService;

    private final SysMenuService sysMenuService;

    @GetMapping("get-menu-tree")
    public Ret getMenuTree() {
        List<SysMenu> list =
                sysMenuService.list();
        return Ret.ok(menuService.buildMenuTree(list));
    }

    @GetMapping("get-catalog-tree")
    public Ret getCatalogTree() {
        List<MenuVo> tree = menuService.getCatalogTree();

        return Ret.ok(tree);
    }
}
